package com.chuangsi.project.admin.controller.admin;


import com.chuangsi.common.exception.ServiceException;
import com.chuangsi.framework.aspectj.lang.annotation.Log;
import com.chuangsi.framework.aspectj.lang.enums.BusinessType;
import com.chuangsi.framework.web.controller.BaseController;
import com.chuangsi.framework.web.domain.ResultObject;
import com.chuangsi.framework.web.page.TableDataInfo;
import com.chuangsi.project.admin.domain.Brand;
import com.chuangsi.project.admin.dto.admin.brand.ReqBrandDetailDto;
import com.chuangsi.project.admin.dto.admin.brand.ReqBrandUpdateDto;
import com.chuangsi.project.admin.dto.admin.defeat.ReqDefeatPageDto;
import com.chuangsi.project.admin.dto.admin.defeat.ResDefeatPageDto;
import com.chuangsi.project.admin.dto.admin.seal.*;
import com.chuangsi.project.admin.service.SealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * E签宝印章 前端控制器
 * </p>
 *
 * @author 
 * @since 2024-03-30
 */
@Api(tags="E签宝印章")
@RestController
@RequestMapping("/adminApi/seal")
public class SealController extends BaseController {

    @Autowired
    private SealService sealService;

    @ApiOperation(value = "管理员下拉选",notes = "ywb")
    @GetMapping("select")
    public ResultObject<List<ResSealSelectDto>> select(){
        List<ResSealSelectDto> dtoList = sealService.select();
        return ResultObject.ok("查询成功").setData(dtoList);
    }


    @ApiOperation(value = "分页查询",notes = "ywb")
    @GetMapping("/pageQuery")
    public TableDataInfo<ResSealPageDto> pageQuery(ReqSealPageDto dto){
        startPage();
        List<ResSealPageDto> list = sealService.pageQuery(dto);
        return getDataTable(list);
    }

    @ApiOperation(value = "详情",notes = "ywb")
    @GetMapping("/info/{sealId}")
    public ResultObject<ResSealInfoDto> info(@PathVariable String sealId){
        ResSealInfoDto info = sealService.info(sealId);
        return ResultObject.ok("查询成功").setData(info);
    }

    @ApiOperation(value = "新增/修改",notes = "ywb")
    @Log(title = "E签宝印章列表", businessType = BusinessType.UPDATE)
    @PostMapping("/addOrUpdate")
    public ResultObject<Void> addOrUpdate(@RequestBody @Validated ReqSealAddOrUpdateDto req){
        sealService.addOrUpdate(req);
        return ResultObject.ok("操作成功");
    }

    @ApiOperation(value = "更改状态",notes = "ywb")
    @Log(title = "E签宝印章列表", businessType = BusinessType.SET)
    @PostMapping("/changeStatus")
    public ResultObject<Void> changeStatus(@RequestBody @Validated ReqSealChangeStatusDto req){
        sealService.changeStatus(req);
        return ResultObject.ok("更改成功");
    }

    @ApiOperation(value = "刷新配置",notes = "ywb")
    @Log(title = "E签宝印章列表", businessType = BusinessType.SET)
    @PostMapping("/refreshConfiguration")
    public ResultObject<Void> refreshConfiguration(){
        sealService.refreshConfiguration();
        return ResultObject.ok("刷新成功");
    }


}
